<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>监室管理系统 - 楼层布局</title>
    <style>
        :root {
            --primary-color: #2c3e50;
            --secondary-color: #3498db;
            --background: #f8f9fa;
        }

        body {
            font-family: 'Segoe UI', system-ui, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: var(--background);
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
        }

        .stats-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }

        .stat-card {
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            text-align: center;
        }

        .stat-value {
            font-size: 2.5em;
            color: var(--primary-color);
            font-weight: bold;
        }

        .stat-label {
            color: #666;
            margin-top: 8px;
        }

        .floor-card {
            background: white;
            border-radius: 10px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            margin-bottom: 30px;
            padding: 20px;
        }

        .floor-title {
            color: var(--secondary-color);
            border-bottom: 2px solid #eee;
            padding-bottom: 10px;
            margin: 0 0 15px 0;
        }

        .rooms-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
            gap: 15px;
        }

        .room-item {
            background: #f8f9fa;
            padding: 15px;
            border-radius: 8px;
            transition: transform 0.2s;
        }

        .room-item:hover {
            transform: translateY(-3px);
            box-shadow: 0 4px 12px rgba(52,152,219,0.2);
        }

        .room-link {
            color: var(--primary-color);
            text-decoration: none;
            font-weight: 500;
        }

        .room-count {
            display: block;
            color: #666;
            font-size: 0.9em;
            margin-top: 8px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>监区房间分布总览</h1>

        <!-- 统计信息 -->
        <div class="stats-container">
            <div class="stat-card">
                <div class="stat-value">{{ total_persons }}</div>
                <div class="stat-label">总在押人数</div>
            </div>
            <div class="stat-card">
                <div class="stat-value">{{ floors|length }}</div>
                <div class="stat-label">总楼层数</div>
            </div>
            <div class="stat-card">
                <div class="stat-value">{{ total_rooms }}</div>
                <div class="stat-label">总房间数</div>
            </div>
        </div>

        <!-- 楼层布局 -->
        {% for floor_num, rooms in floors.items() %}
        <div class="floor-card">
            <h2 class="floor-title">
                第{{ floor_num }}层
                <span style="color:#666;font-size:0.8em;margin-left:15px;">
                    （本层人数：{{ floor_counts[floor_num] }}，房间数：{{ rooms|length }}）
                </span>
            </h2>
            <div class="rooms-grid">
                {% for room in rooms %}
                <div class="room-item">
                    <a href="/room/{{ room.number }}" class="room-link">
                        {{ room.number }}号监室
                    </a>
                    <span class="room-count">当前人数：{{ room.count }}</span>
                </div>
                {% endfor %}
            </div>
        </div>
        {% endfor %}
    </div>
</body>
</html>